<template>
  <div class="Deposit-warp1">
    <div class="Maxtitle">{{ lang.input_title }}</div>
    <div class="payListBox">
      <div class="pix_input_box">
        <div>{{ userStore.moneyUnit }}</div>
        <input
          type="number"
          min="10"
          max="50000"
          class="money_input"
          :value="formData.payNum"
          @input="changeInput"
        />
        <NuxtImg src="/images/carteira/pix.png" />
      </div>
      <div class="youget_box">
        <div class="title">
          <span>{{ lang.input_intro }}</span>
        </div>
        <div class="money">
          <span
            >{{ input_after_num }}
            <!----></span
          >
        </div>
      </div>
      <div class="list">
        <ul>
          <li
            :class="{ active: activeMoney.id === item.id }"
            v-for="item in moneyList"
            :key="item.id"
            @click="checkMoney(item)"
          >
            <span>{{ userStore.moneyUnit }} {{ item.money }}</span>
            <div class="gift" v-if="item.gift && showGifg">
              +{{ item.gift }}%
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>
  <div class="FirstCharge" @click="showGifg = !showGifg">
    <div
      class="FirstChargeImg"
      :class="{ FirstChargeCheck: showGifg }"
      disabled="false"
    ></div>
    <span>{{ lang.first_charge_title }}</span>
  </div>
</template>

<script setup lang="ts">
const lang: any = getCurrentPageLang("carteira");

defineProps(["formData"]);
const emits = defineEmits(["changeFormData"]);

const userStore = useUserStore();

const input_after_num = ref(
  `${userStore.moneyUnit} 15000,00 + ${userStore.moneyUnit} 30000,00`
);

const activeMoney: any = ref({});
const showGifg = ref(true);

const moneyList = ref([
  {
    id: 1,
    money: 15,
    gift: null,
  },
  {
    id: 2,
    money: 30,
    gift: 105,
  },
  {
    id: 3,
    money: 100,
    gift: 115,
  },
  {
    id: 4,
    money: 200,
    gift: 120,
  },
  {
    id: 5,
    money: 300,
  },
  {
    id: 6,
    money: 500,
    gift: 125,
  },
  {
    id: 7,
    money: 1000,
    gift: 135,
  },
  {
    id: 8,
    money: 2000,
    gift: 150,
  },
  {
    id: 9,
    money: 5000,
    gift: 170,
  },
]);

// 选择
function checkMoney(item?: any) {
  item = item || moneyList.value[0];
  activeMoney.value = item;
  emits("changeFormData", { key: "payNum", value: item.money });
}
// 初始化数据
onMounted(() => {
  initData();
});
watch(
  () => userStore.showCarteira,
  (val) => {
    if (!val) return;
    initData();
  }
);
// 弹窗每次打开时，回到第一个选择，打开gifg显示
function initData() {
  showGifg.value = true;
  checkMoney();
}

// 输入
function changeInput(ev: any) {
  activeMoney.value = {};
  emits("changeFormData", {
    key: "payNum",
    value: ev.target.value?.trim(),
  });
}
</script>

<style scoped lang="scss">
.Deposit-warp1 {
  margin-top: 0.25rem;
  background: #3f2e4b;
  border-radius: 0.3rem;
  padding: 0.32rem;
}
.Maxtitle {
  color: var(--theme-neutral1);
  font-size: 0.44rem;
  font-weight: 700;
}
.payListBox {
  border-radius: 0.15rem;
}
.pix_input_box {
  height: 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 0.2rem;
  border: 0.03rem solid var(--border-color);
  background: #2c1d31;
  margin: 0.25rem 0 0.35rem;
  padding: 0 0.4rem;
}
.pix_input_box div {
  width: 1.7rem;
  color: var(--theme-dec4);
  font-size: 0.54rem;
  font-weight: 600;
  position: relative;
}
.pix_input_box div:before {
  content: "";
  width: 0.04rem;
  height: 0.6rem;
  background: var(--border-color);
  position: absolute;
  right: 0;
}
.pix_input_box .money_input {
  border: none;
  background-color: transparent;
  color: var(--theme-neutral1);
  width: 100%;
  font-weight: 700;
  margin-left: 0.4rem;
  font-size: 0.54rem;
}
.pix_input_box img {
  width: 1.61rem;
  height: 0.56rem;
}
.youget_box {
  display: flex;
  margin-bottom: 0.7rem;
}
.youget_box .title {
  color: #c08eba;
  height: 100%;
  text-align: center;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.38rem;
}
.youget_box .money {
  height: 100%;
  color: #ffba00;
  display: flex;
  justify-content: right;
  align-items: center;
  padding: 0 0.25rem;
  border-radius: 0.2rem;
}
.youget_box .money span {
  font-size: 0.44rem;
  font-weight: 600;
}
.list ul {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: 0.25rem;
  row-gap: 0.5rem;
}
.list ul li.active {
  background: linear-gradient(to right, #e154ae, #f380c6);
}
.list ul li {
  cursor: pointer;
  position: relative;
  height: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #291632;
  color: var(--theme-neutral1);
  font-weight: 100;
  border-radius: 1rem;
  transition: all 0.3s ease;
}
.list ul li > span {
  font-size: 0.45rem;
}
.list ul li.active .gift {
  color: var(--theme-neutral1);
  background: #ff2e2e;
}
.list ul li .gift {
  position: absolute;
  top: -0.3rem;
  right: -0.1rem;
  width: 1.35rem;
  border-radius: 0.3rem 0.3rem 0.3rem 0;
  text-align: center;
  padding: 0.1rem 0;
  font-size: 0.32rem;
  font-weight: 800;
  color: #3b1d33;
  background: #ffd700;
}
.FirstCharge {
  display: flex;
  margin-top: 0.46rem;
  align-items: center;
  margin-bottom: 0.46rem;
  color: #a3d3ff;
}
.FirstCharge .FirstChargeImg {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 1rem;
  border: 1px solid var(--border-color);
  margin-right: 0.25rem;
  background-color: #291632;
}
.FirstCharge .FirstChargeCheck {
  background-image: url("/images/layout/icon-correct.png");
  background-size: 100% 100%;
  border: none;
}
</style>
